package e.odbo.data.dsl.query;

import java.util.List;

public class QBF {
    private QBFParameters qbfParameters;

    private QBF(){
        this.qbfParameters=new QBFParameters();
    }

    public static QBF c(){
        return c(false);
    }

    public static QBF c(boolean all){
        QBF qbf= new QBF();
        if(all)
            qbf.and(QBFParameter.ALL);
        return qbf;
    }

    public static QBFParameters all(){
        return c(true).build();
    }

    public static class S {
        public static QBFParameters eq(String field,Object value){
            return c().eq(field,value).build();
        }

        //QBF param calc
        public  static QBFParameters eq(String[] fields,String[] values){
            return c().eq(fields,values).build();
        }

        public static QBFParameters eqNot(String field,Object value){
            return c().eqNot(field,value).build();
        }

        public static QBFParameters in(String field,List values){
           return c().in(field,values).build();
        }

        public static QBFParameters nul(String field) {
           return c().nul(field).build();
        }

        public static QBFParameters notNul(String field){
            return c().notNul(field).build();
        }

        public static QBFParameters like(String field,String value){
           return c().like(field,value).build();
        }

        public static QBFParameters le(String field,Object value){
            return c().le(field,value).build();
        }

        public static QBFParameters leVeq(String field,Object value){
            return c().leVeq(field,value).build();
        }

        public static QBFParameters ge(String field,Object value){
            return c().ge(field,value).build();
        }

        public static QBFParameters geVeq(String field,Object value){
            return c().geVeq(field,value).build();
        }
    }

    public QBFParameters build(){
        return  qbfParameters;
    }

    //QBF param calc
    public  QBF eq(String[] fields,String[] values){
        for(int i=0;i<fields.length;i++)
           qbfParameters.and(new QBFParameter(fields[i]).equal(values[i]));
        return this;
    }

    public QBF eq(String field,Object value){
         qbfParameters.and(new QBFParameter(field).equal(value));
         return this;
    }

    public QBF eqNot(String field,Object value){
        qbfParameters.and(new QBFParameter(field).distanct(value));
        return this;
    }

    public QBF in(String field,List values){
         qbfParameters.and(new QBFParameter(field).in(values));
         return this;
    }

    public QBF nul(String field) {
        qbfParameters.and(new QBFParameter(field).isNull());
        return this;
    }

    public QBF notNul(String field){
        qbfParameters.and(new QBFParameter(field).isNotNull());
        return this;
    }

    public QBF like(String field,String value){
        qbfParameters.and(new QBFParameter(field).like(value));
        return this;
    }

    public QBF le(String field,Object value){
        qbfParameters.and(new QBFParameter(field).less(value));
        return this;
    }

    public QBF leVeq(String field,Object value){
        qbfParameters.and(new QBFParameter(field).lessOrEqual(value));
        return this;
    }

    public QBF ge(String field,Object value){
        qbfParameters.and(new QBFParameter(field).greater(value));
        return  this;
    }

    public QBF geVeq(String field,Object value){
        qbfParameters.and(new QBFParameter(field).greaterOrEqual(value));
        return  this;
    }

    //QBF calc
    public QBF and(QBFParameter qbfParameter){
        qbfParameters.and(qbfParameter);
        return this;
    }

    public QBF and(QBFParameters otherParameters){
        qbfParameters.and(otherParameters);
        return this;
    }

    public QBF or(QBFParameter qbfParameter){
        qbfParameters.or(qbfParameter);
        return this;
    }

    public QBF or(QBFParameters others){
        qbfParameters.or(others);
        return this;
    }
}
